package com.party.core.service.commune.impl;

import com.party.common.paging.Page;
import com.party.core.dao.read.commune.CMemberRecommendReadDao;
import com.party.core.dao.write.commune.CMemberRecommendWriteDao;
import com.party.core.model.BaseModel;
import com.party.core.model.commune.CMemberRecommend;
import com.party.core.service.commune.ICMemberRecommendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Set;

/**
 * @program: party
 * @description: C端用户推荐关系服务实现
 * @author: Hua Qunhao
 * @create: 2019-08-12 14:32
 **/
@Service
public class CMemberRecommendService implements ICMemberRecommendService {
    @Autowired
    private CMemberRecommendReadDao cMemberRecommendReadDao;
    @Autowired
    private CMemberRecommendWriteDao cMemberRecommendWriteDao;


    @Override
    public String insert(CMemberRecommend cMemberRecommend) {
        BaseModel.preInsert(cMemberRecommend);
        BaseModel.preByInfo(cMemberRecommend.getCreateBy(),cMemberRecommend);
        boolean result = cMemberRecommendWriteDao.insert(cMemberRecommend);
        if (result) {
            return cMemberRecommend.getId();
        }
        return null;
    }

    @Override
    public boolean update(CMemberRecommend cMemberRecommend) {
        cMemberRecommend.setUpdateDate(new Date());
        return cMemberRecommendWriteDao.update(cMemberRecommend);
    }

    @Override
    public boolean deleteLogic(String id) {
        return false;
    }

    @Override
    public boolean delete(String id) {
        return cMemberRecommendWriteDao.delete(id);
    }

    @Override
    public boolean batchDeleteLogic(Set<String> ids) {
        return false;
    }

    @Override
    public boolean batchDelete(Set<String> ids) {
        return false;
    }

    @Override
    public CMemberRecommend get(String id) {
        return cMemberRecommendReadDao.get(id);
    }

    @Override
    public List<CMemberRecommend> listPage(CMemberRecommend cMemberRecommend, Page page) {
        return cMemberRecommendReadDao.listPage(cMemberRecommend,page);
    }

    @Override
    public List<CMemberRecommend> list(CMemberRecommend cMemberRecommend) {
        return cMemberRecommendReadDao.listPage(cMemberRecommend,null);
    }

    @Override
    public List<CMemberRecommend> batchList(Set<String> ids, CMemberRecommend cMemberRecommend, Page page) {
        return null;
    }
}
